home *** CD-ROM | disk | FTP | other *** search
- %% This is file `docstrip.tex' generated
- %% on <1991/2/1> with the docstrip utility (v1.1l test).
- %%
- %% The original source file was `docstrip.doc'.
- %% Included modules: `stats'.
- %%
- %% IMPORTANT NOTICE:
- %% You are not allowed to distribute this file.
- %% For distribution of the original source see
- %% the copyright notice in the file `docstrip.doc'.
- %%
- \def\filename{docstrip}
- \def\fileversion{v1.1l test}
- \def\filedate{90/12/10}
- \def\docdate {90/06/15}
-
- %% \CheckSum{835}
- %% \CharacterTable
- %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
- %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
- %% Digits \0\1\2\3\4\5\6\7\8\9
- %% Exclamation \! Double quote \" Hash (number) \#
- %% Dollar \$ Percent \% Ampersand \&
- %% Acute accent \' Left paren \( Right paren \)
- %% Asterisk \* Plus \+ Comma \,
- %% Minus \- Point \. Solidus \/
- %% Colon \: Semicolon \; Less than \<
- %% Equals \= Greater than \> Question mark \?
- %% Commercial at \@ Left bracket \[ Backslash \\
- %% Right bracket \] Circumflex \^ Underscore \_
- %% Grave accent \` Left brace \{ Vertical bar \|
- %% Right brace \} Tilde \~}
- %%
- \nofiles
-
- \makeatletter
-
-
- %% correcting a LaTeX bug first...
- \def\@xtypein[#1]#2{\typeout{#2}\read\sixt@@n to#1\ifx #1\@defpar
- \def#1{}\else
- \@iden{\expandafter\@strip\expandafter
- #1#1\@gobble\@gobble} \@gobble\fi\@typein}
-
- \typeout{LaTeX utility: `docstrip'
- \fileversion\space <\filedate> (FMi)}
- \typeout{English documentation
- \@spaces\@spaces\space\space <\docdate> (FMi)}
- \typeout{}
- \typeout{**********************************************************}
- \typeout{* This program converts documented macro-files into fast *}
- \typeout{* loadable files by stripping of (nearly) all comments!
- \space*}
- \typeout{**********************************************************}
- \typeout{}
-
- \def\test@batchfile{%
- \ifx\undefined\batchfile
- \let\batchfile\default@batchfile
- \@okaytrue \else \@okayfalse \fi
- \openin\batch@stream \batchfile\relax
- \ifeof\batch@stream
- \if@okay \else
- \typeout{*************************************************}
- \typeout{* Could not find your \string\batchfile=\batchfile}
- \typeout{* Try to continue without it}
- \typeout{*************************************************}
- \fi
- \else
- \if@okay
- \typeout{*************************************************}
- \typeout{* Batch file docstrip.cmd found. Use it ? (y/n) *}
- \typein[\answer]
- {*************************************************}
- \def\@tempa{y}%
- \else \let\answer\@tempa \fi
- \ifx\@tempa\answer \process@batchfile \fi
- \fi}
-
- \def\ask@questions{%
- \typeout{}
- \typeout{***************************************************}
- \typeout{* First type the extension of your input file(s): *}
- \typein[\infileext]
- {***************************************************}
- \typeout{}
- \typeout{**************************************************}
- \typeout{* Now type the extension of your output file(s): *}
- \typein[\outfileext]
- {**************************************************}
- \typeout{}
- \typeout{**************************************************}
- \typeout{* Now give the name(s) of module(s) to include: \space *}
- \typein[\includelist]
- {**************************************************}
- \typeout{}
- \typeout{**************************************************}
- \typeout{* Finally give the list of input file(s) without *}
- \typeout{* extension separated by commas if necessary:\@spaces*}
- \typein[\filelist]
- {**************************************************}}
-
- \newif\if@okay
- \newread\@infile
- \newread\@outfile
-
- \def^^L{ }
-
- \def\set@filenames{%
- \edef\in@filename{\main@filename.\infileext}%
- \edef\out@filename{\main@filename.\outfileext}}
-
- \def\check@filenames{%
- \ifx\infileext\outfilext
- \typeout{}
- \typeout{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- \typeout{! Not possible to read from and write to the same file !}
- \typeout{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- \@okayfalse
- \else
- \@okaytrue
- \immediate\openin\@infile \in@filename \relax
- \ifeof \@infile
- \@okayfalse
- \typeout{}
- \typeout{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- \typeout{! Input file `\in@filename' not found !}
- \typeout{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- \else
- \check@outfile
- \fi
- \immediate\closein\@infile
- \fi}
-
- \def\check@outfile{%
- \immediate\openin\@outfile \out@filename \relax
- \ifeof \@outfile \@okaytrue
- \else
- \@okayfalse
- \typeout{}
- \typeout{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- \typeout{! Output file `\out@filename' already exists.}
- \typeout{! Do you want to overwrite it? (yes/no)}
- \typein[\answer]{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- \def\@tempa{yes}%
- \ifx\answer\@tempa \@okaytrue \fi
- \fi
- \immediate\closein\@outfile}
-
- \def\write@postamble{%
- \owrite{\string\endinput}%
- \owrite{\double@percent}%
- \owrite{\double@percent End of file `\out@filename'.}%
- \immediate\closeout\@outfile}
-
- \newcount\numberof@files
- \newcount\meta@comment
- \newcount\normal@comment
- \newcount\code@line
- \newcount\processed@line
- \newcount\summeta@comment
- \newcount\sumnormal@comment
- \newcount\sumcode@line
- \newcount\sumprocessed@line
-
- \def\process@line{%
- \advance\processed@line\@ne
- \futurelet\next\process@@line}
-
- \begingroup
- \catcode`\*=12
- \lccode`\*=`\%
- \lowercase{%
- \gdef\double@percent{** }
- \gdef\percent@{*}
- \gdef\process@@line{%
- \if*\next
- \expandafter\check@second
- \else
- \advance\code@line\@ne
- \endlast@module
- \expandafter\put@line
- \fi}
- \gdef\check@@second{%
- \if*\next
- \advance\meta@comment\@ne
- \endlast@module
- \let\next\put@line
- \else
- \if<\next
- \let\next\check@module
- \else
- \advance\normal@comment\@ne
- \endlast@module
- \let\next\remove@line
- \fi
- \fi
- \next}
- }
-
- \endgroup
-
- \gdef\check@second#1{\futurelet\next\check@@second}
-
- \def\check@module<{\futurelet\next\check@@module}
-
- \def\check@@module{%
- \if+\next
- \let\next\plus@module
- \else
- \if-\next
- \let\next\minus@module
- \else
- \if*\next
- \let\next\star@module
- \else
- \if/\next
- \let\next\slash@module
- \else
- \advance\normal@comment\@ne
- \endlast@module
- \let\next\remove@line
- \fi
- \fi
- \fi
- \fi
- \next}
-
- \def\module@included#1#2{%
- \ifin@line@module
- \def\@tempa{#1#2}%
- \ifx\@tempa\curr@module \else
- \maybe@message{>}\in@line@modulefalse \module@included#1{#2}\fi
- \else
- \in@line@moduletrue
- \def\curr@module{#1#2}%
- \maybe@message{<#1#2}%
- \inclcurr@modulefalse
- \@for\@tempa:=#2\do
- {\edef\@tempb{\noexpand\in@{\@tempa,}{\includelist,}}%
- \@tempb \ifin@ \inclcurr@moduletrue \fi}%
- \fi
- }
-
- \def\endlast@module{%
- \ifin@line@module
- \maybe@message{>}\in@line@modulefalse \fi}
-
- \newif\ifin@line@module
- \newif\ifinclcurr@module
-
- \def\plus@module+#1>{%
- \module@included+{#1}%
- \ifinclcurr@module
- \advance\code@line\@ne
- \expandafter\put@module
- \else
- \advance\normal@comment\@ne
- \expandafter\remove@line
- \fi}
-
- \newif\ifoutput@block \output@blocktrue
- \newif\ifin@block
-
- \def\star@module*#1>{%
- \ifin@block
- \errmessage{Already in block <\block@type>}%
- \else
- \in@blocktrue
- \def\block@type{*#1}%
- \module@included*{#1}%
- \in@line@modulefalse
- \ifinclcurr@module
- \output@blocktrue
- \else
- \output@blockfalse
- \fi
- \fi
- \advance\normal@comment\@ne
- \remove@line
- }
-
- \def\slash@module/#1>{%
- \ifin@block
- \in@blockfalse
- \output@blocktrue
- \maybe@message{\percent@}%
- \maybe@message{>}%
- \def\@tempa{*#1}%
- \ifx\@tempa\block@type
- \else
- \errmessage{Block <\block@type> ended by </#1>}%
- \fi
- \else
- \errmessage{There was no start block for </#1>}%
- \fi
- \advance\normal@comment\@ne
- \remove@line
- }
-
- \def\minus@module-#1>{%
- \module@included-{#1}%
- \ifinclcurr@module
- \advance\normal@comment\@ne
- \expandafter\remove@line
- \else
- \advance\code@line\@ne
- \expandafter\put@module
- \fi}
-
- \def\in@#1#2{%
- \def\in@@##1#1##2##3\in@@{%
- \ifx\in@##2\in@false\else\in@true\fi}%
- \in@@#2#1\in@\in@@}
-
- \newif\ifin@
-
- \def\include#1{\def\includelist{#1}}
-
- \include{}
-
- \def\owrite{%
- \maybe@message{.}%
- \immediate\write\@outfile}
-
- \let\end@inline\relax
-
- \def\put@module#1\end@inline{\owrite{#1}}
-
- \def\put@line#1\end@inline{%
- \ifoutput@block
- \owrite{\in@line}%
- \else
- \maybe@message{\percent@}%
- \fi
- }
-
- \def\remove@line#1\end@inline{%
- \maybe@message{\percent@}%
- }
-
- \def\setup@reading{%
- \immediate\openin\@infile \in@filename \relax
- \@sanitize
- \@makeother\{%
- \@makeother\}%
- \endlinechar\m@ne
- \par@cnt\z@}
-
- \edef\end@input{\expandafter\@gobble\string\\endinput}
-
- \newcount\par@cnt
-
- \def\process@file{%
- \typeout{}%
- \typeout{Processing \in@filename\space
- \ifx\includelist\@empty \else
- (\includelist) \fi
- -> \out@filename}%
- \typeout{}%
- \begingroup
- \setup@reading
- \loop
- \read\@infile to\in@line
- \ifx\end@input\in@line
- \typeout{File \in@filename\space
- ended by \string\endinput.}%
- \@tempswafalse % end the loop
- \else
- \ifx\@empty\in@line
- \advance\par@cnt\@ne
- \else
- \par@cnt\z@
- \fi
- \ifnum \par@cnt<2
- \expandafter\process@line\in@line\end@inline
- \else
- \maybe@message{/}%
- \fi
- \ifeof\@infile \@tempswafalse \else \@tempswatrue \fi
- \fi
- \if@tempswa
- \repeat
- \immediate\closein\@infile
- \typeout{Lines \space processed: \the\processed@line}
- \typeout{Comments removed: \the\normal@comment}
- \typeout{Comments \space passed: \the\meta@comment}
- \typeout{Codelines passed: \the\code@line}
- \global\advance\sumprocessed@line\processed@line
- \global\advance\sumnormal@comment\normal@comment
- \global\advance\summeta@comment\meta@comment
- \global\advance\sumcode@line\code@line
- \global\advance\numberof@files\@ne
- \endgroup}
-
- \def\generatefile#1#2#3{%
- \def\out@filename{#1}%
- \typeout{}%
- \typeout{Generating \out@filename:}%
- \typeout{}%
- \if#2t\check@outfile\else\@okaytrue\fi
- \if@okay
- \def\from##1##2{\owrite{\double@percent ##1
- \if!##2!\else \space
- (with modules: `##2')\fi}}%
- \edef\reference@lines{\owrite{\double@percent }%
- \owrite{\double@percent The original source files were:}%
- \owrite{\double@percent }%
- #3}%
- \def\from##1##2{\def\in@filename{##1}%
- \def\includelist{##2}%
- \process@file}%
- \write@preamble#3\write@postamble
- \let\reference@lines\original@refs
- \fi}
-
- \def\processfile#1#2#3#4{%
- \def\main@filename{#1}%
- \def\infileext{#2}%
- \def\outfileext{#3}%
- \set@filenames
- \if #4t\check@filenames\fi
- \if@okay
- \write@preamble
- \process@file
- \write@postamble
- \else \@okaytrue \fi}
-
- \def\write@preamble{%
- \immediate\openout\@outfile \out@filename \relax
- \owrite{\double@percent This is file `\out@filename' generated}%
- \owrite{\double@percent on <\the\year/\the\month/\the\day> with
- the docstrip utility (\fileversion). }%
- \reference@lines
- \owrite{\double@percent IMPORTANT NOTICE:}%
- \owrite{\double@percent You are not allowed to distribute this file.}%
- \owrite{\double@percent For distribution of the original source see }%
- \owrite{\double@percent the copyright notice in the file `\in@filename'. }%
- \owrite{\double@percent }}
-
- \def\original@refs{%
- \owrite{\double@percent }%
- \owrite{\double@percent The original source file was `\in@filename'.}%
- \ifx\includelist\@empty\else
- \owrite{\double@percent Included modules: `\includelist'.}\fi
- \owrite{\double@percent }}
-
- \let\reference@lines\original@refs
-
- \def\default@batchfile{docstrip.cmd}
-
-
- \def\showprogress{\let\maybe@message\message}
- \def\keepsilent{\let\maybe@message\@gobble}
-
- \def\preamble{\begingroup
- \let\reference@lines\relax
- \let\out@filename\relax
- \let\in@filename\relax
- \@tempswatrue
- \def\@tempa{\endpreamble}%
- \def\@tempb{\par}%
- \gdef\write@preamble{%
- \immediate\openout\@outfile \out@filename \relax
- \owrite{\double@percent }%
- \owrite{\double@percent This is file `\out@filename' generated}%
- \owrite{\double@percent on <\the\year/\the\month/\the\day> with
- the docstrip utility (\fileversion). }%
- \reference@lines}%
- \loop
- \read\batch@stream to \batch@line % get stuff for preamble
- \ifx\batch@line\@tempa \@tempswafalse \else
- \xdef\write@preamble{\write@preamble\owrite
- {\double@percent
- \ifx\batch@line\@tempb\else\batch@line\fi}}\fi
- \if@tempswa
- \repeat\endgroup}
-
- \def\postamble{\begingroup
- \@tempswatrue
- \def\@tempa{\endpostamble}%
- \def\@tempb{\par}%
- \gdef\write@postamble{}%
- \loop
- \read\batch@stream to \batch@line % get stuff for postamble
- \ifx\batch@line\@tempa \@tempswafalse \else
- \xdef\write@postamble{\write@postamble\owrite
- {\double@percent
- \ifx\batch@line\@tempb\else\batch@line\fi}}\fi
- \if@tempswa
- \repeat\endgroup
- \xdef\write@postamble{\write@postamble
- \immediate\closeout\@outfile}}
-
- \newif\ifmore@files \more@filestrue
-
- \newread\batch@stream
-
- \def\process@batchfile{%
- \@okaytrue
- \let\endinput\@okayfalse
- \loop
- \ifeof\batch@stream \@okayfalse \else
- \read\batch@stream to \batch@line % get input line
- \batch@line
- \fi
- \if@okay
- \repeat
- \more@filesfalse}
-
-
- \showprogress
-
- \test@batchfile
-
- \@whilesw\ifmore@files\fi
- {\ask@questions
- \@for\main@filename:=\filelist \do
- {\set@filenames
- \check@filenames
- \if@okay
- \write@preamble
- \process@file
- \write@postamble
- \fi}%
- \typein[\answer]{More files to process? (yes/no)}
- \def\@tempa{yes}%
- \ifx\answer\@tempa \else \more@filesfalse \fi}
-
- \typeout{}
- \ifnum\numberof@files>\@ne
- \typeout{Overall statistics:}
- \typeout{Files \space processed: \the\numberof@files}
- \typeout{Lines \space processed: \the\sumprocessed@line}
- \typeout{Comments removed: \the\sumnormal@comment}
- \typeout{Comments \space passed: \the\summeta@comment}
- \typeout{Codelines passed: \the\sumcode@line}
- \fi
-
- \@@end
-
-
- \endinput
- %%
- %% End of file `docstrip.tex'.
-